package com.example.aptech2008_hellofragment;

import com.example.aptech2008_hellofragment.Fragment1.onInputCompleteListener;

import android.os.Build;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;

@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class MainActivity extends Activity {
	FragmentManager mFragmentManage;

	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	@SuppressLint("NewApi")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		mFragmentManage = getFragmentManager();
		Fragment1 fragment1 = new Fragment1();
		fragment1.setonInputCompleteListener(mInputCompleteListener);
		FragmentTransaction mTransaction = mFragmentManage.beginTransaction();
		mTransaction.replace(R.id.container, fragment1);
		mTransaction.commit();
	}

	onInputCompleteListener mInputCompleteListener = new onInputCompleteListener() {

		@Override
		public void onInputCompleteListener(String name) {
			Fragment2 fragment2 = Fragment2.newInstante(name);
			FragmentTransaction mTransaction = mFragmentManage
					.beginTransaction();
			mTransaction.replace(R.id.container, fragment2);
			mTransaction.commit();

		}
	};

	
}
